package com.patelski.magic.util;

import java.util.List;

import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
import org.jboss.seam.ScopeType;

import com.patelski.magic.exception.MtgException;
import com.patelski.magic.model.Color;
import com.patelski.magic.model.Edition;
import com.patelski.magic.model.EditionCategorie;
import com.patelski.magic.model.Foil;
import com.patelski.magic.service.EditionCategorieList;

@Stateful
@Name("enumLists")
//@Scope(ScopeType.STATELESS)
public class EnumLists implements EnumListsInterface {
	
	@Logger
	protected Log log;

	/* (non-Javadoc)
	 * @see com.patelski.magic.util.EnumLists#destroy()
	 */
	/* (non-Javadoc)
     * @see com.patelski.magic.util.EnumListsInterface#destroy()
     */
	@Remove
	public void destroy() {
	}

	/* (non-Javadoc)
     * @see com.patelski.magic.util.EnumListsInterface#getFoilArray()
     */
	public Foil[] getFoilArray() {
		return Foil.values();
	}

	/* (non-Javadoc)
     * @see com.patelski.magic.util.EnumListsInterface#getColorArray()
     */
	public Color[] getColorArray() {
		return Color.values();
	}
	
	@In(create = true)
	EditionCategorieList editionCategorieList;
	
	/* (non-Javadoc)
     * @see com.patelski.magic.util.EnumListsInterface#getEditionCategorieArray()
     */
	public EditionCategorie[] getEditionCategorieArray() {
		editionCategorieList.setOrder("name");
		Object[] editionCategoriesArray = editionCategorieList.getResultList().toArray();
		EditionCategorie[] array = new EditionCategorie[editionCategoriesArray.length];
		for (int i = 0; i < editionCategoriesArray.length; i++) {
			array[i] = (EditionCategorie)editionCategoriesArray[i];
		}
		return array;
	}

}
